import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class MinimumScalarProduct {
	private static long[] parseLong(String[] l) {
		long r[] = new long[l.length];
		for(int i = 0; i < l.length; i++)
			r[i] = Long.parseLong(l[i]);
		return r;
	}
	public static void main(String[] args) throws IOException {
		BufferedReader rdr = new BufferedReader(new InputStreamReader(System.in));
		try {
			int N = Integer.parseInt(rdr.readLine());
			for(int n = 1; n <= N; n++) {
				Integer.parseInt(rdr.readLine());
				long[] x = parseLong(rdr.readLine().split(" "));
				long[] y = parseLong(rdr.readLine().split(" "));
				Arrays.sort(x);
				Arrays.sort(y);
				long v = 0;
				for(int i = 0; i < x.length; i++)
					v += x[i] * y[y.length - i - 1];
				System.out.println("Case #" + n + ": " + v);
			}
		} finally {
			rdr.close();
		}
	}
}
